function customerSubmit(){
	domainModel.customer.customerName = $$('customerNameField').getValue();
	domainModel.customer.vat  = $$('customerVATField').getValue();
	domainModel.customer.contactPerson  = $$('customerContactField').getValue();
	domainModel.customer.paymentTerms  = $$('customerPaymentField').getValue();
	domainModel.customer.address.street  = $$('customerStreetField').getValue();
	domainModel.customer.address.postalCode = $$('customerPostalField').getValue();
	domainModel.customer.address.city  = $$('customerCityField').getValue();
	domainModel.customer.address.country  = $$('customerCountryField').getValue();
	
	navigate(2);
}

function projectSubmit(){
	var selectedProject = $$('projectTypeSelection').getValue();
	switch(selectedProject){
		case 'fixedPriceProject':
			domainModel.project.projectType = 'FIXED_PRICE';
			domainModel.project.name = $$('projectFixedNameField').getValue();
			domainModel.project.startDate = $$('projectFixedStartDateField').getValue();
			domainModel.project.endDate = $$('projectFixedEndDateField').getValue();
			domainModel.project.transversalLine = $$('projectFixedTransversalField').getValue();
			domainModel.project.deliveryPractice = $$('projectFixedUnitField').getValue();
			domainModel.project.accountManager = $$('projectFixedAccountManField').getValue();
			domainModel.project.engagamentManager = $$('projectFixedEngagementManField').getValue();
			domainModel.project.deliveryManager = $$('projectFixedDeliveryManField').getValue();
			domainModel.project.fixedPriceAmount = $$('projectFixedFixedPriceField').getValue();
			domainModel.project.invoiceReference = $$('projectFixedreferenceField').getValue();
			domainModel.project.po = $$('projectFixedPOField').getValue();
			domainModel.project.volumeDiscount = $$('projectFixedDiscountField').getValue();
			domainModel.project.appendix = $$('projectFixedAppendixField').getValue();
		break;
		case 'tmProject':
			domainModel.project.projectType = 'TM';
			domainModel.project.name = $$('projectTMNameField').getValue();
			domainModel.project.startDate = $$('projectTMStartDateField').getValue();
			domainModel.project.endDate = $$('projectTMEndDateField').getValue();
			domainModel.project.transversalLine = $$('projectTMTransversalField').getValue();
			domainModel.project.deliveryPractice = $$('projectTMUnitField').getValue();
			domainModel.project.accountManager = $$('projectTMAccountManField').getValue();
			domainModel.project.deliveryManager = $$('projectTMDeliveryManField').getValue();
			domainModel.project.invoiceReference = $$('projectTMreferenceField').getValue();
			domainModel.project.po = $$('projectTMPOField').getValue();
			domainModel.project.appendix = $$('projectTMAppendixField').getValue();							
		break;
		case 'proposalProject':
			domainModel.project.projectType = 'PROPOSAL';
			domainModel.project.name = $$('projectProposalNameField').getValue();
			domainModel.project.startDate = $$('projectProposalStartDateField').getValue();
			domainModel.project.endDate = $$('projectProposalEndDateField').getValue();
			domainModel.project.transversalLine = $$('projectProposalTransversalField').getValue();
			domainModel.project.deliveryPractice = $$('projectProposalUnitField').getValue();
			domainModel.project.accountManager = $$('projectProposalAccountManField').getValue();
			domainModel.project.deliveryManager = $$('projectProposalUnitManField').getValue();
			domainModel.project.engagamentManager = $$('projectProposalBidManField').getValue();
		break;
		case 'internalProject':
			domainModel.project.projectType = 'INTERNAL';
			domainModel.project.name = $$('projectInternalNameField').getValue();
			domainModel.project.startDate = $$('projectInternalStartDateField').getValue();
			domainModel.project.endDate = $$('projectInternalEndDateField').getValue();
			domainModel.project.transversalLine = $$('projectInternalTransversalField').getValue();
			domainModel.project.deliveryPractice = $$('projectInternalUnitField').getValue();
			domainModel.project.accountManager = $$('projectInternalEngagementManField').getValue();
			domainModel.project.deliveryManager = $$('projectInternalUnitManField').getValue();
		break;
		default:
			alert('Project Case: '+selectedProject+' is unknown!');
		break;
	}
	
	navigate(3)
}

function employeeSubmit(){
	var resource = new Subcontractor();
	
	var selectedEmployeeType = $$('employeeTypeSelection').getValue();
	switch(selectedEmployeeType){
		case 'employeeTypeCapBel':
			resource.employee.firstName = $$('employeeTypeCapBelFirstnameField').getValue();
			resource.employee.lastName = $$('employeeTypeCapBelLastNameField').getValue();
			resource.employee.type = 'CAPGEMINI_BELGIUM';
			resource.taskName = $$('employeeTypeCapBelTaskNameField').getValue();
			resource.startDate = $$('employeeTypeCapBelStartDateField').getValue();
			resource.endDate = $$('employeeTypeCapBelEndDateField').getValue();
			resource.percentage = $$('employeeTypeCapBelPercentageField').getValue();
			resource.dailyRate = $$('employeeTypeCapBelDailySalesRateField').getValue();
		break;
		case 'employeeTypeIntSubco':
			resource.companyName = $$().getValue('employeeTypeIntSubcoSupplierField');
			resource.employee.firstName = $$('employeeTypeIntSubcoFirstnameField').getValue();
			resource.employee.lastName = $$('employeeTypeIntSubcoLastNameField').getValue();
			resource.employee.type = 'INTERNAL_SUBCONTRACTOR';
			resource.email = $$('employeeTypeIntSubcoEmailAddressField').getValue();
			resource.taskName = $$('employeeTypeIntSubcoTaskNameField').getValue();
			resource.startDate = $$('employeeTypeIntSubcoStartDateField').getValue();
			resource.endDate = $$('employeeTypeIntSubcoEndDateField').getValue();
			resource.percentage = $$('employeeTypeIntSubcoPercentageField').getValue();
			resource.dailyRate = $$('employeeTypeIntSubcoDailySalesRateField').getValue();
			resource.level = $$('employeeTypeIntSubcoEstimatedCgLevel').getValue();
			resource.dailyPurchasePrice = $$('employeeTypeIntSubcoDailyPurchasePriceField').getValue();							
		break;
		case 'employeeTypeExtSubco':
			resource.companyName = $$().getValue('employeeTypeExtSubcoSupplierField');
			resource.employee.firstName = $$('employeeTypeExtSubcoFirstnameField').getValue();
			resource.employee.lastName = $$('employeeTypeExtSubcoLastNameField').getValue();
			resource.employee.type = 'EXTERNAL_SUBCONTRACTOR';
			resource.email = $$('employeeTypeExtSubcoEmailAddressField').getValue();
			resource.taskName = $$('employeeTypeExtSubcoTaskNameField').getValue();
			resource.startDate = $$('employeeTypeExtSubcoStartDateField').getValue();
			resource.endDate = $$('employeeTypeExtSubcoEndDateField').getValue();
			resource.percentage = $$('employeeTypeExtSubcoPercentageField').getValue();
			resource.dailyRate = $$('employeeTypeExtSubcoDailySalesRateField').getValue();
			resource.level = $$('employeeTypeExtSubcoEstimatedCgLevel').getValue();
			resource.dailyPurchasePrice = $$('employeeTypeExtSubcoDailyPurchasePriceField').getValue();
		break;
		case 'employeeTypeIndianSubco':
			resource.companyName = $$().getValue('employeeTypeIndianSubcoSupplierField');
			resource.firstName = $$('employeeTypeIndianSubcoFirstnameField').getValue();
			resource.lastName = $$('employeeTypeIndianSubcoLastNameField').getValue();
			resource.type = 'INDIAN_SUBCONTRACTOR';
			resource.email = $$('employeeTypeIndianSubcoEmailAddressField').getValue();
			resource.taskName = $$('employeeTypeIndianSubcoTaskNameField').getValue();
			resource.startDate = $$('employeeTypeIndianSubcoStartDateField').getValue();
			resource.endDate = $$('employeeTypeIndianSubcoEndDateField').getValue();
			resource.percentage = $$('employeeTypeIndianSubcoPercentageField').getValue();
			resource.dailyRate = $$('employeeTypeIndianSubcoDailySalesRateField').getValue();
			resource.level = $$('employeeTypeIndianSubcoEstimatedCgLevel').getValue();
			resource.dailyPurchasePrice = $$('employeeTypeIndianSubcoDailyPurchasePriceField').getValue();							
		break;
		default:
			alert('Customer Case: '+selectedEmployeeType+' is unknown!');
		break;
	}
	
	domainModel.addResource(resource);
	
	navigate(3);
}

function addEmployee(){
	navigate(5);
}

function doneAddingEmployees(){
	navigate(4);
}

function sendORF(){	
	$$('successForm').show();
	alert('Domain Model: '+domainModel.toString());
}

function navigate(toFormNumber){
	if(toFormNumber == 1){//CustomerInfo
		$$('formDescription').config.label='Customer Info';
		$$("formDescription").refresh();
		$$('indexList').select(1);
		$$('customerInfoForm').show();
	}else if(toFormNumber == 2){//ProjectInfo
		$$('formDescription').config.label='Project Info';
		$$("formDescription").refresh();
		$$('indexList').select(2);
		$$('projectInfoForm').show();
	}else if(toFormNumber == 3){//EmployeeOverview
		$$('formDescription').config.label='Employee Overview';
		$$("formDescription").refresh();
		$$('indexList').select(3);
		
		//code for filling up the label -> should be removed
		var labelText = '';
		if(domainModel.resources.length == 0){
			labelText = 'No Employees yet';
		}else{
			for(var i = 0; i < domainModel.resources.length; i++){
				var r = domainModel.resources[i];
				labelText += r.employee.firstName+' '+r.employee.lastName+', ';
			}
		}								
		$$('employeeOverviewLabel').config.label=labelText;
		$$('employeeOverviewLabel').refresh();
		
		$$('employeeOverviewForm').show();
	}else if(toFormNumber == 4){//Checkout
		$$('formDescription').config.label='Checkout & Send';
		$$("formDescription").refresh();
		$$('indexList').select(4);
		$$('checkoutForm').show();
	}else if(toFormNumber == 5){//employee overview
		$$('formDescription').config.label='Employee Info';
		$$("formDescription").refresh();
		$$('indexList').select(3);
		$$('employeeForm').show();
	}
}